﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AlexandriaPressUserBusinessLayer;
using AlexandriaPressUserObject;

namespace AlexandriaPressWebsite.MasterPages.UserPages
{
    public partial class AuthorApplicationPage : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            UserBusinsessLayer business = new UserBusinsessLayer();
            string _UserType = business.getUserType(HttpContext.Current.User.Identity.Name);
            if (_UserType == "Type_Buyer" || _UserType == "Type_Admin" || _UserType == "Type_ProofReader" || _UserType == "Type_Author")
            {

            }
            else
            {
                Response.Redirect("~/MasterPages/ErrorPage.aspx");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (Session["blocked"] != null)
                {
                    Session.RemoveAll();
                    Response.Redirect("~/MasterPages/MainPage.aspx");
                }
            }
            else
            {
                Session.RemoveAll();
                Response.Redirect("~/MasterPages/MainPage.aspx");
            }
        }

        protected void SubmitApplicationButton_Click(object sender, EventArgs e)
        {
            if (CheckBox1.Checked)
            {
                UserBusinsessLayer.applyToBeAuthor(Convert.ToInt32(Session["userID"]));
                errorMessageLabel.Text = "Your Application has been submitted.";

                SubmitApplicationButton.Visible = false;
                CheckBox1.Visible = false;
            }
            else

                errorMessageLabel.Text = "You have not agreed to the terms and conditions.";
        }
    }
}
